
	//act = delete|confirm , param=nomination|vote , u_id=user_id , n_id=nomination_id
	function do_action(act, param, u_id, n_id) {
		if (act=='delete') a = confirm("Are you sure you want to delete this "+param+"?");
		else a = true;
		if (a == true) {
			new Ajax.Request(self.location+'?ajax=1', {
				method:'get',
				parameters: { action:''+act, type:''+param, user_id:''+u_id, nomination_id:''+n_id}, 
				onLoading: function() { $('search-loading').toggle('appear'); },
				onComplete: function() { $('search-loading').toggle('appear'); },
				onSuccess: function(transport) { do_search('') },
				onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
			});
		}
		return false;
	}
	
	function mark_celeb(u_id, stat) {
		new Ajax.Request(self.location+'?ajax=1', {
			method:'get',
			parameters: { action:'markceleb', user_id:''+u_id, status:''+stat}, 
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { do_search('') },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;
	}
	
	function member_vote(n_id, stat) {
		new Ajax.Request(self.location+'?ajax=1', {
			method:'get',
			parameters: { action:'membervote', nomination_id:''+n_id, status:''+stat}, 
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { if (transport.responseText) $('error_msg').innerHTML = x; else { $('error_msg').innerHTML = "<br />"; do_search(''); } },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;
	}	
			
	allFuncs["ResetSearchForm"] = function(sort) {
		$('searchfield').value = 'contestant.url';
		$('search').value = '';
		$('filtercategory').value = '';
		$('filterconfirmed').value = '';
		new Ajax.Request(self.location+'?ajax=1&reset=1', {
			parameters: $('searchform').serialize(true), 
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;
	}
	
	allFuncs["SubmitSearch"] = function() { do_search(''); return false; }
	
	function do_search(sort) {
		var valid = new Validation('searchform', {immediate:true});
		if (valid.validate()) {
			new Ajax.Request(self.location+'?ajax=1&sort='+sort, {
				parameters: $('searchform').serialize(true), 
				onLoading: function() { $('search-loading').toggle('appear'); },
				onComplete: function() { $('search-loading').toggle('appear'); },
				onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
				onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
			});
		}
		return false;
	}
	
	
	function nominations_per_page() {
		new Ajax.Request(self.location+'?ajax=1&filtercount='+$('filtercount').value, {
			method:'get',
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;	
	}
	
	function previous_page() {
		new Ajax.Request(self.location+'?ajax=1&countprevious=1', {
			method:'get',
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;	
	}
	
	function change_page() {
		new Ajax.Request(self.location+'?ajax=1&filterpage='+$('filterpage').value, {
			method:'get',
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;	
	}
	
	function next_page() {
		new Ajax.Request(self.location+'?ajax=1&countnext=1', {
			method:'get',
			onLoading: function() { $('search-loading').toggle('appear'); },
			onComplete: function() { $('search-loading').toggle('appear'); },
			onSuccess: function(transport) { $('nomination_results').innerHTML = transport.responseText; },
			onFailure: function(transport) { $('nomination_results').innerHTML = " Ajax Request Failed "; }
		});
		return false;
	}
	
Event.onDOMReady(function() {
	do_search('');
});
